www.gusucode.com > VC++ 客户管理系统(SQL Serve)-源码程序 > VC++ 客户管理系统(SQL Serve)-源码程序/code/Program/khlogin.cpp
// khlogin.cpp : implementation file // #include "stdafx.h" #include "khmanager.h" #include "khlogin.h" #include "Resource.h" #include "ado.h" #include "khmain.h" #include "elet2.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // khlogin dialog khlogin::khlogin(CWnd* pParent /*=NULL*/) : CDialog(khlogin::IDD, pParent) { //{{AFX_DATA_INIT(khlogin) //}}AFX_DATA_INIT } void khlogin::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(khlogin) DDX_Control(pDX, IDC_BUTTON2, m_button2); DDX_Control(pDX, IDC_BUTTON1, m_button1); DDX_Control(pDX, IDC_EDIT2, m_mima); DDX_Control(pDX, IDC_EDIT1, m_name); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(khlogin, CDialog) //{{AFX_MSG_MAP(khlogin) ON_WM_PAINT() ON_BN_CLICKED(IDC_BUTTON1, OnButton1) ON_WM_LBUTTONDOWN() ON_BN_CLICKED(IDC_BUTTON2, OnButton2) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // khlogin message handlers BOOL khlogin::OnInitDialog() { CDialog::OnInitDialog(); m_button1.SetBitmap(LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP1))); //设置位图 m_button2.SetBitmap(LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP2))); //设置位图 unsigned short usReadLen; CString strtext; long ret = EleT2Read(0,(unsigned char *)strtext.GetBuffer(0),sizeof(strtext),&usReadLen); switch(ret) { case ELE_T2_NO_MORE_DEVICE : MessageBox("没有找到相应的模板设备"); break; case ELE_T2_INVALID_PASSWORD : MessageBox("无效的密码"); break; case ELE_T2_INSUFFICIENT_BUFFER: MessageBox("缓冲区不足"); break; case ELE_T2_BEYOND_DATA_SIZE: MessageBox("读写数据区越界"); break; } if(ret != ELE_T2_SUCCESS || strtext != "123") { MessageBox("请插入指定的加密锁"); CDialog::OnCancel(); } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void khlogin::OnPaint() { CPaintDC dc(this); // device context for painting CBitmap bit; CDC mendc; CRect rect; this->GetWindowRect(&rect); bit.LoadBitmap(IDB_BITMAP8); mendc.CreateCompatibleDC(&dc); mendc.SelectObject(&bit); dc.BitBlt(0,0,rect.Width(),rect.Height(),&mendc,0,0,SRCCOPY); mendc.DeleteDC(); ::DeleteObject(&bit); // TODO: Add your message handler code here // Do not call CDialog::OnPaint() for painting messages } void khlogin::OnButton1() { ado rst; CString sql,name,mima,mima2; this->m_name.GetWindowText(name); this->m_mima.GetWindowText(mima); sql.Format("select * from tb_user where user_name ='%s'",name); rst.Open(sql,adCmdText); if(rst.GetRecordCount()<1) { MessageBox("您输入的用户不存在!请重新输入!","系统提示",MB_OK|MB_ICONSTOP); m_name.SetWindowText(""); m_name.SetFocus(); return; } else { mima2=rst.GetFieldValue("user_mm"); if(mima2==mima) { this->OnCancel(); khmain main; main.DoModal(); } else { MessageBox("您输入的密码不正确!请重新输入!","系统提示",MB_OK|MB_ICONSTOP); m_mima.SetWindowText(""); m_mima.SetFocus(); return; } } } void khlogin::OnLButtonDown(UINT nFlags, CPoint point) { ::SendMessage(this->GetSafeHwnd(),WM_SYSCOMMAND,SC_MOVE+2,0); CDialog::OnLButtonDown(nFlags, point); } void khlogin::OnButton2() { CDialog::OnCancel(); }